<template>
  <div class="snow-page">
    <a-card title="危险源详情" style="width: 99%" hoverable>
      <template #extra>
        <a-button size="mini" type="primary" @click="goBack">返回</a-button>
      </template>
      <a-descriptions title="" layout="vertical" bordered :column="5">
        <a-descriptions-item label="重大危险源编码">{{ qiyeInfo.hazard_code }}</a-descriptions-item>
        <a-descriptions-item label="重大危险源名称">{{ qiyeInfo.hazard_name }}</a-descriptions-item>
        <a-descriptions-item label="重大危险源简称">{{ qiyeInfo.hazard_short_name }}</a-descriptions-item>

        <a-descriptions-item label="危险源等级">{{ (qiyeInfo.hazard_rank_name) }}</a-descriptions-item>
        <a-descriptions-item label="R值">{{ qiyeInfo.rvalue }}</a-descriptions-item>
        <a-descriptions-item label="行政区域编码">{{ qiyeInfo.area_code }}</a-descriptions-item>
        <a-descriptions-item label="地址">{{ qiyeInfo.address }}</a-descriptions-item>
        <a-descriptions-item label="经纬度">{{ qiyeInfo.lon }},{{ qiyeInfo.lat }}</a-descriptions-item>
        <a-descriptions-item label="投用日期">{{ formatTime(qiyeInfo.establish_date) }}</a-descriptions-item>
        <a-descriptions-item label="周边防护目标最近距离（米）">{{ qiyeInfo.protection_target_distance }}</a-descriptions-item>
        <a-descriptions-item label="外边界500米范围人数估算">{{ qiyeInfo.people_500m }}</a-descriptions-item>
        <a-descriptions-item label="库房基本信息">{{ qiyeInfo.basic_info }}</a-descriptions-item>
        <a-descriptions-item label="库房的最大储存量">{{ qiyeInfo.max_storage }}</a-descriptions-item>
        <a-descriptions-item label="库房储存物品类别">{{ qiyeInfo.goods_type }}</a-descriptions-item>
        <a-descriptions-item label="库房安全操作规程">{{ qiyeInfo.safe_operation }}</a-descriptions-item>
        <a-descriptions-item label="最大罐组">{{ qiyeInfo.max_group }}</a-descriptions-item>
        <a-descriptions-item label="是否在化工园区内">{{ qiyeInfo.in_industrial_park == "1" ? '是' : '否' }}</a-descriptions-item>
        <a-descriptions-item label="所属化工园区名称">{{ qiyeInfo.industrial_park_name }}</a-descriptions-item>

      </a-descriptions>
    </a-card>
  </div>
</template>

<script setup lang="ts">
import { onMounted, ref } from "vue";
import { getDictBycodeAPI } from "@/api/modules/dictionary/index";
const router = useRouter();

const qiyeInfo = ref({}) as any;

onMounted(() => {


  let userInfo = JSON.parse(localStorage.getItem("user-info") as string);
  if (userInfo) {
    qiyeInfo.value = userInfo.sharedObject;
  }

  getDictBycodeAPIfun();

});
const options597 = ref([]);
async function getDictBycodeAPIfun() {
  // let obj={}
  let res = await getDictBycodeAPI(597);
  if (res.status == 2) {
    options597.value = res.data;
    qiyeInfo.value.hazard_rank_name = format597(qiyeInfo.value.hazard_rank)
  }
}

function format597(val) {


  let obj = options597.value.filter(e => {
    return e.id == (val);
  });
 

  return obj[0].name;
}


function formatTime(specificTimestamp) {
  // 创建一个Date对象
  if (specificTimestamp) {
    let date = new Date(specificTimestamp);

    let year = date.getFullYear();
    let month = date.getMonth() + 1; // 月份从0开始，需要加1
    let day = date.getDate();

    // 格式化日期字符串
    let formattedDate = `${year}-${month < 10 ? "0" : ""}${month}-${day < 10 ? "0" : ""}${day}`;

    return formattedDate;
  }
}
function goBack() {
  router.back();
}
</script>





<style lang="scss" scoped></style>